package com.zjr.friend.controller.exam;

import com.zjr.common.core.controller.BaseController;
import com.zjr.common.core.domain.R;
import com.zjr.common.core.domain.TableDataInfo;
import com.zjr.friend.domain.exam.dto.ExamQueryDTO;
import com.zjr.friend.service.exam.IExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/exam")
public class ExamController extends BaseController {
    @Autowired
    IExamService iExamService;
    // 从 mysql 中读取数据 - 标题/开始结束时间/是否报名
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO){
        return getTableDataInfo(iExamService.list(examQueryDTO));
    }

    //// 从 redis 中读取数据 - 标题/开始结束时间/是否报名
    @GetMapping("/semiLogin/redis/list")
    public TableDataInfo redisList(ExamQueryDTO examQueryDTO){
        return iExamService.redisList(examQueryDTO);
    }

    @GetMapping("/getFirstQuestion")
    public R<String> getFirstQuestion(Long examId){
        return R.ok(iExamService.getFirstQuestion(examId));
    }

    @GetMapping("/preQuestion")
    public  R<String> preQuestion(Long examId, Long questionId){
        return R.ok(iExamService.preQuestion(examId, questionId));
    }
    @GetMapping("/nextQuestion")
    public  R<String> nextQuestion(Long examId, Long questionId){
        return R.ok(iExamService.nextQuestion(examId, questionId));
    }
}
